package com.xxx.video.mine.adapters;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.xxx.video.R;
import com.xxx.video.commen.adapters.BaseRecycleViewAdapter;
import com.xxx.video.commen.adapters.BaseViewHolder;
import com.xxx.video.commen.utils.StringUtils;
import com.xxx.video.mine.beans.DynamicListBean;

import butterknife.BindView;

public class RecordingManagementListAdapter extends BaseRecycleViewAdapter<DynamicListBean.PageBean.ListBean, RecordingManagementListAdapter.MyHolder> {


    public RecordingManagementListAdapter(@NonNull Context context) {
        super(context);
    }

    @Override
    public MyHolder onCreateDefaultViewHolder(View view, int viewType) {
        return new MyHolder(view);
    }

    @Override
    public int getItemLayout(int viewType) {
        return R.layout.item_recording_management_list;
    }


    class MyHolder extends BaseViewHolder {
        @BindView(R.id.iv_item_recording_management_icon)
        ImageView ivItemRecordingManagementIcon;
        @BindView(R.id.tv_item_recording_management_title)
        TextView tvItemRecordingManagementTitle;
        @BindView(R.id.tv_item_recording_management_time)
        TextView tvItemRecordingManagementTime;
        @BindView(R.id.iv_item_recording_management_delete)
        ImageView ivItemRecordingManagementDelete;
        public MyHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void setData2View(int position) {
            DynamicListBean.PageBean.ListBean listBean = getItem(position);
            /*
             * title
             */
            tvItemRecordingManagementTitle.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.fTitle));
            /*
             * time
             */
            tvItemRecordingManagementTime.setText(StringUtils.getInstance().getNotEmptyMsg(String.valueOf(listBean.fCreateTime)));
            ivItemRecordingManagementDelete.setOnClickListener(v -> {
                if (onItemClickListener!=null){
                    onItemClickListener.onItemClick(listBean,position,1);
                }
            });
        }
    }
}
